<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style1.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/form.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var objs = document.getElementsByName("id");
		var sign = 0;
		for(var i = 0; i < objs.length; i++){
			if(objs[i].value != '0' && objs[i].checked){
				sign = sign + 1;
			}
		}
		if(sign <= 0){
			alert("请选择要删除的项！");
			return false;
		}
		return true;
	}

	function addEmployeeBBS(){
		window.location.href = "./employeeBBS.do?action=preAddEmployeeBBS";
		window.location.target = "main";
	}
	
	function deleteEmployeeBBS(){
		if(checkForm()){
			document.employeeBBSForm.action = "./employeeBBS.do?action=deleteEmployeeBBS";
			document.employeeBBSForm.target = "main";
			document.employeeBBSForm.submit();
		}
	}
	
	function viewEmployeeBBS(id){
		window.location.href = "./employeeBBS.do?action=viewEmployeeBBS&id="+id;
		window.location.target = "main";
	}
	
	function searchEmployeeBBS(){
		var subject = document.getElementById("subject");
		if(subject.value == ""){
			alert("请输入关键字!");
		}else{
			document.getElementById("sFlag").value = "1";
			document.employeeBBSForm.action = "./employeeBBS.do";
			document.employeeBBSForm.target = "main";
			document.employeeBBSForm.submit();
		}
	}
	
	function pageCustomer(flag){
		document.employeeBBSForm.action = "./employeeBBS.do?action=display&flag="+flag;
		document.employeeBBSForm.target = "main";
		document.employeeBBSForm.submit();
	}
	
	function initPage(){
		if("<c:out value='${result}'/>" == 1){
			alert("删除成功！");
		}
	}
-->
</script>
</head>
<body onload="initPage()">
<form name="employeeBBSForm" action="" method="post">
<table class="table_frame">
		<tr>
			<td>
				<table class="table_title1">
					<tr>
						<td class="title_lab" colspan="2">员工论坛</td>
					</tr>
					<tr>
						<td valign="bottom" class="a_tools" style="padding-left: 3px;">关键字：
							<input id="subject" name="subject" class="input_query" type="text" value="${subject}"/>
							<input id="sFlag" name="sFlag" type="hidden" value="${sFlag}"/>
							<a class="search" href="javascript:searchEmployeeBBS();" target="main" hidefocus="true">查询</a>
							|
							<c:if test="${isManageEmployeeBBS == 1 || isAddEmployeeBBS == 1}">
							<a class="add" href="javascript:addEmployeeBBS();" title="发布信息" hidefocus="true">新增</a>
							</c:if>
							<c:if test="${isManageEmployeeBBS == 1 || isDeleteEmployeeBBS == 1}">
							<a class="del" href="javascript:deleteEmployeeBBS();" title="删除" hidefocus="true">删除</a>
							</c:if>
						</td>
						<td></td>
					</tr>
					<tr><td height="2" colspan="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td>
				<table class="table_title2">
					<tr>
						<td class="title_lab">论坛帖子列表</td>
						<td align="right" valign="">
							<!-- page -->
							<table class="table_page2">
								<tr>
									<td valign="bottom">
										<img src="./images/frist.bmp" onclick="pageCustomer(1)" alt="首页" style="vertical-align: middle;cursor: hand;">
										<img src="./images/last.bmp" onclick="pageCustomer(2)" alt="上一页" style="vertical-align: middle;cursor: hand;">&nbsp;
										<font color="red">${currentPage}</font>/${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;
										<img src="./images/next.bmp" onclick="pageCustomer(3)" alt="下一页" style="vertical-align: middle;cursor: hand;">
										<img src="./images/end.bmp" onclick="pageCustomer(4)" alt="末页" style="vertical-align: middle;cursor: hand;">
										共&nbsp;&nbsp;${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>&nbsp;&nbsp;&nbsp;
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr><td colspan="3" height="2"></td></tr>
					<tr>
						<td colspan="2">
							<table class="table">
								<tr>
									<td valign="top">
										<!-- 
										<div style="width:800px;height:100%;overflow-x: scroll;overflow-y: hidden;">
										 -->
										<table class="table_style">
											<tr>
												<td class="title" width="8"></td>
												<td class="title" width="30">选择
													<!-- <input id="id" name="id" type="checkbox" value="0" onclick="checkAll('id')"/> -->
												</td>
												<td class="title">信息主题</td>
												<td class="title" width="12%">发帖人</td>
												<td class="title" width="15%">发布日期</td>
												<td class="title" width="12%">回复/浏览</td>
											</tr>
											<c:forEach var="employeeBBS" items="${employeeBBSs}">
											<tr onmouseover="onmousemoveChange(this,'img${employeeBBS.id}')" onmouseout="onmouseoutChange(this,'img${employeeBBS.id}')">
												<td height="16" width="8" align="right"><img id="img${employeeBBS.id}" src="./images/table_sign2.bmp"></td>
												<td><input id="id" name="id" type="checkbox" value="${employeeBBS.id}"/></td>
												<td align="left">
													<a href="javascript:viewEmployeeBBS('${employeeBBS.id}');" title="${employeeBBS.subject}" target="main">
													<c:choose>
														<c:when test="${fn:length(employeeBBS.subject) > 26}">${fn:substring(employeeBBS.subject,0,26)}......</c:when>
														<c:otherwise>${employeeBBS.subject}</c:otherwise>
													</c:choose>
													</a>
												</td>
												<td>${employeeBBS.sendPerson}</td>
												<td><fmt:formatDate value="${employeeBBS.sendDate}" pattern="yyyy-MM-dd"/></td>
												<td>
													${fn:length(employeeBBS.comments)}/
													<c:choose>
														<c:when test="${empty employeeBBS.viewNum}">0</c:when>
														<c:otherwise>${employeeBBS.viewNum}</c:otherwise>
													</c:choose>
												</td>
											</tr>
											</c:forEach>
										</table>
										<!-- 
										</div>
										 -->
									</td>
								</tr>
								<tr>
									<td align="left" valign="bottom">
										<!-- page -->
										<table id="tp" class="table_page">
											<tr>
												<td>&nbsp;&nbsp;
													<img src="./images/frist.bmp" onclick="pageCustomer(1)" alt="首页" style="vertical-align: middle;cursor: hand;">
													<img src="./images/last.bmp" onclick="pageCustomer(2)" alt="上一页" style="vertical-align: middle;cursor: hand;">&nbsp;
													<font color="red">${currentPage}</font>/${totalPages}&nbsp;<fmt:message key='common.page'/>&nbsp;
													<img src="./images/next.bmp" onclick="pageCustomer(3)" alt="下一页" style="vertical-align: middle;cursor: hand;">
													<img src="./images/end.bmp" onclick="pageCustomer(4)" alt="末页" style="vertical-align: middle;cursor: hand;">
													共&nbsp;&nbsp;${totalRows}&nbsp;<fmt:message key='common.page.totalRow'/>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>	
</body>
</html>